class Solution:
    def merge(self, nums1: list[int], m: int, nums2: list[int], n: int) -> None:
        """
        Do not return anything, modify nums1 in-place instead.
        """
        flag = n+m-1
        flag1, flag2 = m-1, n-1
        while flag >= 0:
            if flag1 >= 0 and flag2 >= 0:
                if nums1[flag1] > nums2[flag2]:
                    nums1[flag] = nums1[flag1]
                    flag1 -= 1
                    flag -= 1
                else:
                    nums1[flag] = nums2[flag2]
                    flag2 -= 1
                    flag -= 1
            elif flag2 >= 0:
                nums1[flag] = nums2[flag2]
                flag -= 1
                flag2 -= 1
            else:
                return
        return

if __name__ == '__main__':
    s = Solution()
    nums1 = [1,2,3,0,0,0]
    m = 3
    nums2 = [2,5,6]
    n = 3
    s.merge(nums1, m, nums2, n)
    print(nums1)